﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2013-01-01 13:51:46Z</CreationDate>
</File>
*/
#endregion

using System;
using System.Windows;
using Outcoder.Net;

namespace Outcoder.Services.Implementation
{
	public class NetworkMonitoringServiceMock : INetworkMonitoringService
	{
		NetworkConnectionType networkConnectionType = NetworkConnectionType.Lan;

		public event EventHandler<EventArgs> NetworkConnectionChanged;

		public bool ApproachingDataLimit { get; set; }
		public bool Roaming { get; set; }
		public bool LimitData { get; set; }

		public void Update()
		{
			/* Intentionally left blank. */
		}

		public string Ssid { get; set; }

		public virtual bool Connected
		{
			get
			{
				return networkConnectionType != NetworkConnectionType.None;
			}
		}

		public virtual NetworkConnectionType NetworkConnectionType
		{
			get
			{
				return networkConnectionType;
			}
			set
			{
				if (networkConnectionType != value)
				{
					networkConnectionType = value;

					UISynchronizationContext.Instance.InvokeWithoutBlocking(() =>
					{
						NetworkConnectionChanged?.Invoke(this, EventArgs.Empty);

							IMessenger messenger;
							if (Dependency.TryResolve<IMessenger>(out messenger))
							{
								messenger.Publish(new NetworkAvailabilityChangedMessage(
									                   new NetworkConnectionInfo(NetworkConnectionType, LimitData)));
							}
						});
				}
			}
		}

#if __ANDROID__

		public string IPAddress { get; set; }
#endif
	}
}